//
//  NewEventDatePickerCell.swift
//  YOKO
//
//  Created by Zoe_G on 16/5/22.
//  Copyright © 2016年 15Tec. All rights reserved.
//

import UIKit

protocol DatePickerDalegate {
    func dateChanged(date: NSDate)
}

class NewEventDatePickerCell: UITableViewCell {
    
    var isDate: Bool = true
    
    var datePicker: CustomDatePickerView!
    
    var delegate: DatePickerDalegate! = nil
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("Cannot init from coder")
    }
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        datePicker = CustomDatePickerView()
        self.addSubview(datePicker)
        datePicker.snp_makeConstraints {
            make in 
            make.edges.equalTo(self)
        }
        
        datePicker.yearMonthDayDatePicker.commitButton.addTarget(self, action: #selector(NewEventDatePickerCell.dateDidSelected), forControlEvents: .TouchUpInside)
        datePicker.hourMinuteDatePicker.commitButton.addTarget(self, action: #selector(NewEventDatePickerCell.dateDidSelected), forControlEvents: .TouchUpInside)
    }
    
    
    func dateDidSelected() {
        self.delegate.dateChanged(datePicker.date)
    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
